package com.the4man.cnbdw.action;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.opensymphony.xwork2.ModelDriven;
import com.the4man.cnbdw.service.*;
import com.the4man.cnbdw.utils.Page;
import com.the4man.cnbdw.utils.SelectModel;
import com.the4man.framework.action.BaseAction;
import com.the4man.framework.model.*;
import com.the4man.framework.model.gen.RoomExampleBase;
import com.the4man.framework.util.DateUtil;
import com.the4man.framework.util.LOG;
import com.the4man.framework.util.PageJson;
import com.the4man.framework.utils.RequestUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Action(
        value = "roomAction",
        results = {@Result(
                name = "addPage",
                location = "/cnbdw/room/add.jsp"
        ), @Result(
                name = "listPage",
                location = "/cnbdw/room/list.jsp"
        ), @Result(
                name = "roomStateList",
                location = "/cnbdw/roomState/list.jsp"
        ), @Result(
                name = "editPage",
                location = "/cnbdw/room/edit.jsp"
        )}
)
public class RoomAction extends BaseAction implements ModelDriven<Room> {
    private Room room = new Room();
    private LogInfo logInfo = new LogInfo();
    @Autowired
    private LogInfoService logService;
    @Autowired
    private RoomService roomService;
    @Autowired
    private RoomTypeService roomTypeService;
    @Autowired
    private BedInfoService bedInfoService;
    @Autowired
    private ItemInfoService itemInfoService;

    public RoomAction() {
    }

    public String indexPage() {
        return "listPage";
    }

    public String toAddPage() {
        return "addPage";
    }

    public String indexPage1() {
        return "roomStateList";
    }

    public String toEditPage() {
        try {
            Room d = (Room)this.roomService.selectByPrimaryKey(this.getRequest().getParameter("id"), Room.class);
            BeanUtils.copyProperties(d, this.room);
        } catch (Exception var2) {
            var2.printStackTrace();
        }

        return "editPage";
    }

    public void getAllDatasourceList() {
        try {
            RoomExample roomExample = new RoomExample();
            RoomExampleBase.Criteria cc = roomExample.createCriteria();
            if(StringUtils.isNotEmpty(this.room.getRoomNo())) {
                cc.andRoomNoLike("%" + this.room.getRoomNo() + "%");
            }

            if(StringUtils.isNotEmpty(this.room.getDeck())) {
                cc.andDeckEqualTo(this.room.getDeck());
            }

            if(StringUtils.isNotEmpty(this.room.getArea())) {
                cc.andAreaEqualTo(this.room.getArea());
            }

            if(StringUtils.isNotEmpty(this.room.getType())) {
                cc.andTypeEqualTo(this.room.getType());
            }

            if(StringUtils.isNotEmpty(this.room.getProps())) {
                cc.andPropsEqualTo(this.room.getProps());
            }

            int total = this.roomService.countByExample(roomExample);
            Page<Room> page = new Page();
            this.setPageProperties(page);
            this.roomService.selectByExample(roomExample, page);
            DataGrid d = new DataGrid();
            d.setRows(page.getData());
            d.setTotal(Long.valueOf((long)total));
            System.out.println("--------------------------------" + d);
            this.writeJson(d);
        } catch (Exception var6) {
            LOG.error("获取数据失败", var6, new String[0]);
        }

    }

    public void getFullDatasourceList() {
        try {
            RoomExample roomExample = new RoomExample();
            RoomExampleBase.Criteria criteria = roomExample.createCriteria();
            Page<Room> page = new Page();
            if(this.room != null) {
                if(StringUtils.isNotBlank(this.room.getDeck())) {
                    criteria.andDeckEqualTo(this.room.getDeck());
                }

                if(StringUtils.isNotBlank(this.room.getArea())) {
                    criteria.andAreaEqualTo(this.room.getArea());
                }

                if(StringUtils.isNotBlank(this.room.getRoomNo())) {
                    criteria.andRoomNoLike("%" + this.room.getRoomNo() + "%");
                }

                if(StringUtils.isNotBlank(this.room.getType())) {
                    criteria.andTypeEqualTo(this.room.getType());
                }
            }

            this.roomService.selectFullByExample(roomExample, page);
            DataGrid d = new DataGrid();
            d.setRows(page.getData());
            d.setTotal(Long.valueOf((long)page.getRowCount()));
            this.writeJson(d);
        } catch (Exception var5) {
            LOG.error("获取数据失败", var5, new String[0]);
        }

    }

    public void getRoomDatasourceList() {
        try {
            RoomExample roomExample = new RoomExample();
            RoomExampleBase.Criteria criteria = roomExample.createCriteria();
            Page<Room> page = new Page();
            if(this.room != null) {
                if(StringUtils.isNotBlank(this.room.getDeck())) {
                    criteria.andDeckEqualTo(this.room.getDeck());
                }

                if(StringUtils.isNotBlank(this.room.getArea())) {
                    criteria.andAreaEqualTo(this.room.getArea());
                }

                if(StringUtils.isNotBlank(this.room.getRoomNo())) {
                    criteria.andRoomNoLike("%" + this.room.getRoomNo() + "%");
                }

                if(StringUtils.isNotBlank(this.room.getType())) {
                    criteria.andTypeEqualTo(this.room.getType());
                }
            }

            this.roomService.selectRoomByExample(roomExample, page);
            DataGrid d = new DataGrid();
            d.setRows(page.getData());
            d.setTotal(Long.valueOf((long)page.getRowCount()));
            this.writeJson(d);
        } catch (Exception var5) {
            LOG.error("获取数据失败", var5, new String[0]);
        }

    }

    public void getOneDatasourceList() {
        try {
            RoomExample roomExample = new RoomExample();
            RoomExampleBase.Criteria criteria = roomExample.createCriteria();
            Page<Room> page = new Page();
            if(this.room != null) {
                if(StringUtils.isNotBlank(this.room.getDeck())) {
                    criteria.andDeckEqualTo(this.room.getDeck());
                }

                if(StringUtils.isNotBlank(this.room.getArea())) {
                    criteria.andAreaEqualTo(this.room.getArea());
                }

                if(StringUtils.isNotBlank(this.room.getRoomNo())) {
                    criteria.andRoomNoLike("%" + this.room.getRoomNo() + "%");
                }

                if(StringUtils.isNotBlank(this.room.getType())) {
                    criteria.andTypeEqualTo(this.room.getType());
                }
            }

            this.roomService.selectOneByExample(roomExample, page);
            DataGrid d = new DataGrid();
            d.setRows(page.getData());
            d.setTotal(Long.valueOf((long)page.getRowCount()));
            this.writeJson(d);
        } catch (Exception var5) {
            LOG.error("获取数据失败", var5, new String[0]);
        }

    }

    public void getRoomSelectData() {
        try {
            List<SelectModel> list = new ArrayList();
            SelectModel m1 = new SelectModel();
            m1.setId("1");
            m1.setName("model1");
            SelectModel m2 = new SelectModel();
            m2.setId("2");
            m2.setName("model2");
            list.add(m1);
            list.add(m2);
            this.writeJson(list);
        } catch (Exception var4) {
            LOG.error("获取数据失败", var4, new String[0]);
        }

    }

    public void getStateSelectData() {
        try {
            List<SelectModel> list = new ArrayList();
            list.add(new SelectModel("1", "正常"));
            list.add(new SelectModel("2", "损坏"));
            list.add(new SelectModel("3", "丢失"));
            this.writeJson(list);
        } catch (Exception var2) {
            LOG.error("获取数据失败", var2, new String[0]);
        }

    }

    public void add() {
        PageJson json = new PageJson();
        String bedData = this.getRequest().getParameter("bedJson");
        String itemData = this.getRequest().getParameter("itemJson");
        JSONArray valuelist = JSONArray.parseArray(bedData);
        JSONArray valuelist1 = JSONArray.parseArray(itemData);

        try {
            String rm = this.roomService.selectByName(this.room.getRoomNo());
            if(rm == null) {
                String time = DateUtil.getInstance().formatDate(new Date());
                this.room.setId(UUID.randomUUID().toString());
                this.room.setCreateTime(time);
                this.room.setUpdateTime(time);
                this.room.setCreateUser(RequestUtil.getSessionUserinfo().getUsername());
                this.room.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                this.room.setProps(this.getProps());
                this.roomService.insert(this.room);
                this.logInfo.setId(UUID.randomUUID().toString());
                this.logInfo.setTime(time);
                this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                this.logInfo.setFunc("舱室管理");
                this.logInfo.setOp("舱室添加");
                this.logInfo.setMemo("舱室:" + this.room.getRoomNo());
                this.logService.insert(this.logInfo);
                int i;
                JSONObject value;
                String id;
                String itemNo;
                if("1".equals(this.room.getProps())) {
                    for(i = 0; i < valuelist.size(); ++i) {
                        value = valuelist.getJSONObject(i);
                        id = value.getString("id");
                        itemNo = value.getString("bedNo");
                        BedInfo bi;
                        if(StringUtils.isNotEmpty(id)) {
                            bi = (BedInfo)this.bedInfoService.selectByPrimaryKey(id, BedInfo.class);
                            if(bi != null) {
                                bi.setBedNo(itemNo);
                                this.bedInfoService.updateByPrimaryKey(bi);
                                this.logInfo.setId(UUID.randomUUID().toString());
                                this.logInfo.setTime(time);
                                this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                                this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                                this.logInfo.setFunc("舱室管理");
                                this.logInfo.setOp("床位修改");
                                this.logInfo.setMemo("床位:" + itemNo);
                                this.logService.insert(this.logInfo);
                            }
                        } else {
                            bi = new BedInfo();
                            bi.setId(UUID.randomUUID().toString());
                            bi.setBedNo(itemNo);
                            bi.setRoomId(this.room.getId());
                            bi.setUpdateTime(time);
                            bi.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                            this.bedInfoService.insert(bi);
                            this.logInfo.setId(UUID.randomUUID().toString());
                            this.logInfo.setTime(time);
                            this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                            this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                            this.logInfo.setFunc("舱室管理");
                            this.logInfo.setOp("床位添加");
                            this.logInfo.setMemo("床位:" + itemNo);
                            this.logService.insert(this.logInfo);
                        }
                    }
                }

                for(i = 0; i < valuelist1.size(); ++i) {
                    value = valuelist1.getJSONObject(i);
                    id = value.getString("id");
                    itemNo = value.getString("itemNo");
                    String state = value.getString("state");
                    ItemInfo bi;
                    if(StringUtils.isNotEmpty(id)) {
                        bi = (ItemInfo)this.itemInfoService.selectByPrimaryKey(id, ItemInfo.class);
                        if(bi != null) {
                            bi.setItemNo(itemNo);
                            bi.setState(state);
                            this.itemInfoService.updateByPrimaryKey(bi);
                            this.logInfo.setId(UUID.randomUUID().toString());
                            this.logInfo.setTime(time);
                            this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                            this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                            this.logInfo.setFunc("舱室管理");
                            this.logInfo.setOp("物品修改");
                            this.logInfo.setMemo("物品:" + itemNo);
                            this.logService.insert(this.logInfo);
                        }
                    } else {
                        bi = new ItemInfo();
                        bi.setId(UUID.randomUUID().toString());
                        bi.setItemNo(itemNo);
                        bi.setState(state);
                        bi.setRoomId(this.room.getId());
                        bi.setUpdateTime(time);
                        bi.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                        this.itemInfoService.insert(bi);
                        this.logInfo.setId(UUID.randomUUID().toString());
                        this.logInfo.setTime(time);
                        this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                        this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                        this.logInfo.setFunc("舱室管理");
                        this.logInfo.setOp("物品添加");
                        this.logInfo.setMemo("物品:" + itemNo);
                        this.logService.insert(this.logInfo);
                    }
                }

                json.setReturnFlag(true);
                json.setReturnMsg("提交成功！");
            } else {
                json.setReturnFlag(false);
                json.setReturnMsg("该舱室名已存在");
            }
        } catch (Exception var14) {
            json.setReturnFlag(false);
            json.setReturnMsg("提交出错了");
            LOG.error("获取数据失败", var14, new String[0]);
        }

        this.writeJson(json);
    }

    public void insertBedData() {
        String time = DateUtil.getInstance().formatDate(new Date());
        String roomId = this.getRequest().getParameter("roomId");
        String bedId = this.getRequest().getParameter("bedId");
        String bedNo = this.getRequest().getParameter("bedNo");

        try {
            BedInfo b;
            if(bedId != null && bedId != "") {
                b = (BedInfo)this.bedInfoService.selectByPrimaryKey(bedId, BedInfo.class);
                b.setBedNo(bedNo);
                b.setUpdateTime(time);
                b.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                this.bedInfoService.updateByPrimaryKey(b);
            } else {
                b = new BedInfo();
                b.setId(UUID.randomUUID().toString());
                b.setBedNo(bedNo);
                b.setRoomId(roomId);
                b.setCreateTime(time);
                b.setUpdateTime(time);
                b.setCreateUser(RequestUtil.getSessionUserinfo().getUsername());
                b.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                this.bedInfoService.insert(b);
            }
        } catch (Exception var6) {
            var6.printStackTrace();
        }

    }

    public void updateRoomLocked() {
        String doorNo = this.getRequest().getParameter("doorNo");
        String lock = this.getRequest().getParameter("lock");

        try {
            this.roomService.updateRoomLocked(doorNo, lock);
        } catch (Exception var4) {
            ;
        }

    }

    public void update() {
        String bedData = this.getRequest().getParameter("bedJson");
        String itemData = this.getRequest().getParameter("itemJson");
        PageJson json = new PageJson();

        try {
            JSONArray valuelist = JSONArray.parseArray(bedData);
            JSONArray valuelist1 = JSONArray.parseArray(itemData);
            String rid = this.room.getId();
            String name = this.room.getRoomNo();
            String rm = this.roomService.selectMByName(rid, name);
            if(rm == null) {
                this.room.setUpdateTime(DateUtil.getInstance().formatDate(new Date()));
                this.room.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                this.room.setProps(this.getProps());
                int a = this.roomService.updateByPrimaryKey(this.room);
                this.logInfo.setId(UUID.randomUUID().toString());
                this.logInfo.setTime(DateUtil.getInstance().formatDate(new Date()));
                this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                this.logInfo.setFunc("舱室管理");
                this.logInfo.setOp("舱室修改");
                this.logInfo.setMemo("舱室:" + this.room.getRoomNo());
                this.logService.insert(this.logInfo);
                JSONObject value;
                String id;
                String itemNo;
                int i;
                String state;
                if("1".equals(this.room.getProps())) {
                    for(i = 0; i < valuelist.size(); ++i) {
                        value = valuelist.getJSONObject(i);
                        id = value.getString("id");
                        itemNo = value.getString("bedNo");
                        if(StringUtils.isNotEmpty(id)) {
                            BedInfo bi = (BedInfo)this.bedInfoService.selectByPrimaryKey(id, BedInfo.class);
                            if(bi != null) {
                                bi.setBedNo(itemNo);
                                this.bedInfoService.updateByPrimaryKey(bi);
                                this.logInfo.setId(UUID.randomUUID().toString());
                                this.logInfo.setTime(DateUtil.getInstance().formatDate(new Date()));
                                this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                                this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                                this.logInfo.setFunc("舱室管理");
                                this.logInfo.setOp("床位修改");
                                this.logInfo.setMemo("床位:" + itemNo);
                                this.logService.insert(this.logInfo);
                            }
                        } else {
                            state = DateUtil.getInstance().formatDate(new Date());
                            BedInfo bi = new BedInfo();
                            bi.setId(UUID.randomUUID().toString());
                            bi.setBedNo(itemNo);
                            bi.setRoomId(this.room.getId());
                            bi.setUpdateTime(state);
                            bi.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                            this.bedInfoService.insert(bi);
                            this.logInfo.setId(UUID.randomUUID().toString());
                            this.logInfo.setTime(state);
                            this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                            this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                            this.logInfo.setFunc("舱室管理");
                            this.logInfo.setOp("床位添加");
                            this.logInfo.setMemo("床位:" + itemNo);
                            this.logService.insert(this.logInfo);
                        }
                    }
                } else {
                    BedInfoExample example = new BedInfoExample();
                    example.createCriteria().andRoomIdEqualTo(this.room.getId());
                    this.bedInfoService.deleteByExample(example);
                }

                for(i = 0; i < valuelist1.size(); ++i) {
                    value = valuelist1.getJSONObject(i);
                    id = value.getString("id");
                    itemNo = value.getString("itemNo");
                    state = value.getString("state");
                    ItemInfo bi;
                    String time;
                    if(StringUtils.isNotEmpty(id)) {
                        time = DateUtil.getInstance().formatDate(new Date());
                        bi = (ItemInfo)this.itemInfoService.selectByPrimaryKey(id, ItemInfo.class);
                        if(bi != null) {
                            bi.setItemNo(itemNo);
                            bi.setState(state);
                            bi.setUpdateTime(time);
                            this.itemInfoService.updateByPrimaryKey(bi);
                            this.logInfo.setId(UUID.randomUUID().toString());
                            this.logInfo.setTime(time);
                            this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                            this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                            this.logInfo.setFunc("舱室管理");
                            this.logInfo.setOp("物品修改");
                            this.logInfo.setMemo("物品:" + itemNo);
                            this.logService.insert(this.logInfo);
                        }
                    } else {
                        time = DateUtil.getInstance().formatDate(new Date());
                        bi = new ItemInfo();
                        bi.setId(UUID.randomUUID().toString());
                        bi.setItemNo(itemNo);
                        bi.setState(state);
                        bi.setRoomId(this.room.getId());
                        bi.setUpdateTime(time);
                        bi.setUpdateUser(RequestUtil.getSessionUserinfo().getUsername());
                        this.itemInfoService.insert(bi);
                        this.logInfo.setId(UUID.randomUUID().toString());
                        this.logInfo.setTime(time);
                        this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                        this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                        this.logInfo.setFunc("舱室管理");
                        this.logInfo.setOp("物品添加");
                        this.logInfo.setMemo("物品:" + itemNo);
                        this.logService.insert(this.logInfo);
                    }
                }

                json.setReturnFlag(true);
                json.setReturnMsg("提交成功！");
            } else {
                json.setReturnFlag(false);
                json.setReturnMsg("该舱室名已存在");
            }
        } catch (Exception var17) {
            json.setReturnFlag(false);
            json.setReturnMsg("提交出错了");
            LOG.error("获取数据失败", var17, new String[0]);
        }

        this.writeJson(json);
    }

    public String executeModifyResult() {
        try {
            Object instance = this.roomService.selectByPrimaryKey(this.room.getId(), Room.class);
            this.getRequest().setAttribute("instance", instance);
        } catch (Exception var2) {
            LOG.error("获取数据失败", var2, new String[0]);
        }

        return "modifyPage";
    }

    public void delete() {
        PageJson json = new PageJson();
        String time = DateUtil.getInstance().formatDate(new Date());

        try {
            int count = 0;
            String ids = this.getRequest().getParameter("ids");
            if(ids.contains(",")) {
                String[] str = ids.split(",");
                String[] var9 = str;
                int var8 = str.length;

                for(int var17 = 0; var17 < var8; ++var17) {
                    String info = var9[var17];
                    Room d = (Room)this.roomService.selectByPrimaryKey(info, Room.class);
                    int i = this.roomService.deleteByPrimaryKey(info, Room.class);
                    this.logInfo.setId(UUID.randomUUID().toString());
                    this.logInfo.setTime(time);
                    this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                    this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                    this.logInfo.setFunc("舱室管理");
                    this.logInfo.setOp("舱室删除");
                    this.logInfo.setMemo("舱室:" + d.getRoomNo());
                    this.logService.insert(this.logInfo);
                    BedInfoExample example = new BedInfoExample();
                    example.createCriteria().andRoomIdEqualTo(info);
                    this.bedInfoService.deleteByExample(example);
                    ItemInfoExample example1 = new ItemInfoExample();
                    example1.createCriteria().andRoomIdEqualTo(info);
                    this.itemInfoService.deleteByExample(example1);
                    if(i > 0) {
                        ++count;
                    }
                }
            } else {
                Room d = (Room)this.roomService.selectByPrimaryKey(this.getRequest().getParameter("ids"), Room.class);
                count = this.roomService.deleteByPrimaryKey(this.getRequest().getParameter("ids"), Room.class);
                this.logInfo.setId(UUID.randomUUID().toString());
                this.logInfo.setTime(time);
                this.logInfo.setUserName(RequestUtil.getSessionUserinfo().getUsername());
                this.logInfo.setUserId(RequestUtil.getSessionUserinfo().getUserid());
                this.logInfo.setFunc("舱室管理");
                this.logInfo.setOp("舱室删除");
                this.logInfo.setMemo("舱室:" + d.getRoomNo());
                this.logService.insert(this.logInfo);
                BedInfoExample example = new BedInfoExample();
                example.createCriteria().andRoomIdEqualTo(this.getRequest().getParameter("ids"));
                this.bedInfoService.deleteByExample(example);
                ItemInfoExample example1 = new ItemInfoExample();
                example1.createCriteria().andRoomIdEqualTo(this.getRequest().getParameter("ids"));
                this.itemInfoService.deleteByExample(example1);
            }

            if(count > 0) {
                json.setReturnMsg("成功删除" + count + "个舱室！");
                json.setReturnFlag(true);
            } else {
                json.setReturnMsg("删除舱室失败！");
                json.setReturnFlag(false);
            }
        } catch (Exception var14) {
            LOG.error("批量删除舱室失败！", var14, new String[0]);
            json.setReturnMsg("删除舱室失败！");
            json.setReturnFlag(false);
        }

        this.writeJson(json);
    }

    public void deleteBed() {
        PageJson json = new PageJson();

        try {
            int count = this.bedInfoService.deleteByPrimaryKey(this.room.getId(), BedInfo.class);
            if(count > 0) {
                json.setReturnMsg("成功删除床位！");
                json.setReturnFlag(true);
            } else {
                json.setReturnMsg("删除床位失败！");
                json.setReturnFlag(false);
            }
        } catch (Exception var3) {
            var3.printStackTrace();
            LOG.error("删除床位失败！", var3, new String[0]);
            json.setReturnMsg("删除床位失败！");
            json.setReturnFlag(false);
        }

        this.writeJson(json);
    }

    public void deleteItem() {
        PageJson json = new PageJson();

        try {
            int count = this.itemInfoService.deleteByPrimaryKey(this.room.getId(), ItemInfo.class);
            if(count > 0) {
                json.setReturnMsg("成功删除物品！");
                json.setReturnFlag(true);
            } else {
                json.setReturnMsg("删除物品失败！");
                json.setReturnFlag(false);
            }
        } catch (Exception var3) {
            var3.printStackTrace();
            LOG.error("删除物品失败！", var3, new String[0]);
            json.setReturnMsg("删除物品失败！");
            json.setReturnFlag(false);
        }

        this.writeJson(json);
    }

    public void verify() {
        PageJson json = new PageJson();
        this.writeJson(json);
    }

    private String getProps() {
        RoomType rt = null;

        try {
            rt = (RoomType)this.roomTypeService.selectByPrimaryKey(this.room.getType(), RoomType.class);
        } catch (Exception var3) {
            ;
        }

        return "" + rt.getType();
    }

    public void getBedInfoList() {
        try {
            new PageJson();
            BedInfoExample example = new BedInfoExample();
            example.createCriteria().andRoomIdEqualTo(this.room.getId());
            List<BedInfo> listb = this.bedInfoService.selectByExample(example);
            this.writeJson(listb);
        } catch (Exception var4) {
            var4.printStackTrace();
        }

    }

    public void getItemInfoList() {
        try {
            new PageJson();
            ItemInfoExample example = new ItemInfoExample();
            example.createCriteria().andRoomIdEqualTo(this.room.getId());
            List<ItemInfo> listi = this.itemInfoService.selectByExample(example);
            this.writeJson(listi);
        } catch (Exception var4) {
            var4.printStackTrace();
        }

    }

    public Room getModel() {
        return this.room;
    }
}
